#ifndef CHANGEPASSDIALOG_H
#define CHANGEPASSDIALOG_H

#include <QDialog>
#include <QMovie>
#include <QThread>
#include <DataProvider.h>

class PassProc;

namespace Ui {
class ChangePassDialog;
}

class ChangePassDialog : public QDialog
{
	Q_OBJECT

	QMovie* _movie;
	PassProc* _thread;
	DataProvider* _provider;

	Ui::ChangePassDialog *ui;
	
public:
	explicit ChangePassDialog(DataProvider* provider, QWidget *parent = 0);
	~ChangePassDialog();
	void setCurrentPass(CipherType::Enum type, QString pass);
	
private:
	void startGif();
	void stopGif();

public slots:
	void onBtnChange();
	void onBtnCancel();
	void done();

signals:
	void passChaged(CipherType::Enum type, QString pass);
};


class PassProc : public QThread
{
	Q_OBJECT

	bool _isRunning;
	DataProvider* _provider;

	CipherType::Enum _prevType;
	CipherType::Enum _newType;
	QString _prevPass;
	QString _newPass;

public:
	explicit PassProc(DataProvider* provider, QObject *parent = 0);
	void stop();
	void setData(CipherType::Enum prevType, CipherType::Enum newType, QString prevPass, QString newPass);

protected:
	void run();

signals:
	void done();
	void showMessage(QString msg);

};

#endif // CHANGEPASSDIALOG_H
